<!Doctype html>
<html>
<head>
<meta charset="utf-8">
<title>rey</title>
<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
<script src="jquery-3.3.1.js"></script>
<script language="javascript" type="text/javascript">
function checkFormdef(){
var registName=$("#user");
var email=$("#email");
var uBirthday=$("#birthday");
var registpad=$("#registpad");
var registpas=$("#registpas");
var registNumber=$("#registnumber");

if($("#user").val()==""){
alert("用户名不能为空");
registName.focus();
registName.css("border","2px solid red");
return false;
}

//var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if($("#email").val()==""||!myreg.test($("#email").val())){
alert("邮箱格式不正确");
email.focus();
email.css("border","2px solid red");

return false;
}

if($("uBirthday").val()==""){
alert("生日不能为空");
uBirthday.focus();
uBirthday.css("border","2px solid red");
return false;
}

if($("#registpad").val().length<6||$("#registpad").val().length>6){
alert("密码长度为6位！！");
registpad.focus();
registpad.css("border","2px solid red");
return false;
}else
{
  if(!(/[A-Z]/.test($("#registpad").val().charAt(0)))){
    alert("密码首位必须为大写字母且长度为6位！");
	registpad.focus();
	registpad.css("border","2px solid red");
	return false;
  }
}

if($("#registpad").val()!==$("#registpas").val()){
alert("两次输入密码不一致");
registpas.focus();
registpas.css("border","2px solid red");
return false;
}


if($("#registNumber").val()==""){
alert("电话号码不能为空");
registNumber.focus();
registNumber.css("border","2px solid red");
return false;
}else{
if($("#registNumber").val().length!=11||isNaN($("#registNumber").val())){
alert("电话长度为11位且均为数字");
registNumber.focus();
registNumber.css("border","2px solid red");
return false;
}


}


}
</script>
</head>
<body>
<form action="" method="get" onsubmit="return checkFormdef()">
<table border="1" align="center">
<tr>
<td>用户名：</td>
<td><input type="text" name="username" id="user"/></td>
</tr>
<tr>
<td>邮箱:</td>
<td><input type="text" name="email" id="email"/></td>
</tr>
 <tr>
 <td>出生日期  </td>
 <td><input class="Wdate" type="text" id="birthday" autocomplete="off" onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'})" /></td>
 </tr>
 
<tr>
<td>密码：</td>
<td><input type="password"  name="password"  id="registpad"/></td>
</tr>
<tr>
<td>确认密码</td>
<td><input type="password"  name="repassword" id="registpas"/></td>
</tr>
<tr>
<td>联系电话</td>
<td><input type="text" name="number" id="registnumber"/></td>
</tr>
<tr>
<td colspan="2">性别<input type="radio" name="sex" value="男" id="sex"/>男
<input type="radio" name="sex" value="女" checked="checked"/>女</td>
</tr>
<tr>
<td>提交</td>
<td><input type="submit" value="注册" id="sub"/></td>
</tr>
<tr>
<td>重置</td>
<td><input type="reset"/></td>
</tr>
</table>
</form>
</body>
</html>